//
//  SingleCollectionViewCell.m
//  薄荷家具
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "SingleCollectionViewCell.h"
#import "SingleGoods.h"
#import "UIImageView+WebCache.h"
@implementation SingleCollectionViewCell
-(void)dealloc{
    [_nameLabel release];
    [_picture release];
    [_priceLabel release];
    [_likeLabel release];
    [_single release];
    
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.picture = [[UIImageView alloc]init];
        [self.contentView addSubview:self.picture];
//        self.picture.backgroundColor = [UIColor yellowColor];
        [self.picture release];
        
        
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.numberOfLines = 2;
        
//        self.nameLabel.backgroundColor = [UIColor purpleColor];
        [self addSubview:self.nameLabel];
        [_nameLabel release];
        
        
        
        self.likeLabel = [[UILabel alloc]init];
//        self.likeLabel.backgroundColor = [UIColor blackColor];
        [self addSubview:self.likeLabel];
        [_likeLabel release ];
        
        
        
        self.priceLabel = [[UILabel alloc]init];
//        self.priceLabel.backgroundColor = [UIColor greenColor];
        [self addSubview:self.priceLabel];
        [_priceLabel release];
        
    }
    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.picture.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 80*sHeight);
    
    self.nameLabel.frame = CGRectMake(0, self.frame.size.height - 80*sHeight, self.frame.size.width, 50);
    
    self.priceLabel.frame = CGRectMake(0, self.frame.size.height - 80*sHeight + 50*sHeight, self.frame.size.width / 2, 30);
    self.likeLabel.frame = CGRectMake(self.frame.size.width / 2, self.frame.size.height - 80*sHeight + 50*sHeight, self.frame.size.width / 2, 30);
    
}

-(void)setSingle:(SingleGoods *)single
{
    if (_single != single) {
        [_single release];
        _single = [single retain];
    }
    
    [self.picture sd_setImageWithURL:[NSURL URLWithString:single.cover_image_url]];
    
    self.likeLabel.text = [NSString stringWithFormat:@"❤️%@",single.favorites_count];
    self.priceLabel.text = [NSString stringWithFormat:@"￥:%@", single.price];
    self.nameLabel.text = single.name;
    
    
    
}




@end
